package homework.api.day02;

public class IntegerDemo {
    public static void main(String[] args) {
        //定义Integer对象
        Integer i1 = new Integer(5);
        Integer i2 = new Integer(5);
        System.out.println(i1==i2);
        System.out.println(i1.equals(i2));

        Integer i3 = Integer.valueOf(5);
        Integer i4 = Integer.valueOf(5);
        System.out.println(i3==i4);
        System.out.println(i3.equals(i4));

        //自动拆装箱
        Integer i5 = 5;
        Integer i50 = Integer.valueOf(5);

        int i6 = i5;
        int i60 = i5.intValue();


        //包装类的两种常见操作
        int max = Integer.MAX_VALUE;
        int min = Integer.MIN_VALUE;
        System.out.println(max+",  "+min);

        String num1 = "741";
        if(num1.matches("-?\\d+")){
            int i7 = Integer.parseInt(num1);
            System.out.println(i7);
        }

        String num2 = "-.951";
        if(num2.matches("-?\\d*\\.?\\d*")){
            double i8 = Double.parseDouble(num2);
            System.out.println(i8);
        }

    }
}
